package com.dm.userservice;


import com.springcloud.demo.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.sql.SQLOutput;

@RestController
public class LoginController {

    @Autowired
    private UserFeignClient userFeignClient;

    @GetMapping(value = "/login")
    public String login(){
        System.err.println("测试");
       return userFeignClient.login();
    }

    @PostMapping(value = "/login1")
    public String login1(@RequestParam("name") String name, @RequestParam("pwd") String pwd){
        System.err.println("测试");
        if(userFeignClient.login1(name,pwd)){
            return "连接成功";
        }
        return "失败";
    }

    @PostMapping(value = "/login2")
    public String login2(@RequestParam("name") String name, @RequestParam("pwd") String pwd){
        System.err.println("测试");
        User user = new User();
        user.setUserName(name);
        user.setPassWord(pwd);
        if(userFeignClient.login2(user)){
            return "连接成功";
        }
        return "失败";
    }

    @GetMapping(value = "/login3")
    public String login3(){
        System.err.println("测试");
        for (int i = 0; i < 50; i++) {
            System.out.println(userFeignClient.login3(i));
        }
        return "";
    }
}
